﻿using System.Collections.Generic;
using System.Web.Mvc;
using ThumpThumpBus.Models.Repository;
using ThumpThumpBus.Models.ViewModels;

namespace ThumpThumpBus.Controllers
{
    public class IncidentsController : Controller
    {
        private PersonRepository _personRepository = new PersonRepository();
        private IncidentRepository _incidentRepository = new IncidentRepository();
        
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Report()
        {
            var viewData = new List<PersonViewModel>();
            var people = _personRepository.GetAllPeople();
            foreach (var p in people)
            {
                var person = new PersonViewModel();
                person.PersonId = p.id;
                person.PersonName = p.name;
                person.ThrowCount = _incidentRepository.GetThrowCountByPerson(p);
                person.HitCount = _incidentRepository.GetHitCountByPerson(p);
                viewData.Add(person);
            }

            var model = new ReportIncidentViewModel(viewData);
            return View(model);
        }
    }
}
